home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbedits.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-02-16  |  5.3 KB  |  152 lines

  1. (*===========================================================================*)
  2. (* Edit a file -- Subroutines -- NON overlayed                               *)
  3. (*                                                                           *)
  4. (*   Copyright (c) 1985, 87 by Borland International, Inc.                   *)
  5. (*   Copyright 1988, 1989, 1991 by H. Roy Engehausen.  All rights reserved.  *)
  6. (*                                                                           *)
  7. (*   This code cannot be used in other programs except in conjunction        *)
  8. (*   with a licensed copy of the Turbo Editor Toolbox                        *)
  9. (*                                                                           *)
  10. (*===========================================================================*)
  11.  
  12. {$UNDEF DEBUG_OVER}
  13. {$UNDEF DEBUG_BP}
  14.  
  15. UNIT BBEDITS;
  16.  
  17. INTERFACE
  18.  
  19. USES
  20.   bined;
  21.  
  22. PROCEDURE usereventcheck(eventno, kbdflaginfo : WORD);
  23.  
  24. PROCEDURE executeeditor;
  25.  
  26. (*===========================================================================*)
  27. (* Constants to control the editor                                           *)
  28. (*===========================================================================*)
  29.  
  30. CONST
  31.   myexitcommands :
  32.                ARRAY[0..27] OF CHAR = (#2, ^K, ^Q,
  33.                                        #2, #0, #68,      (* F10 *)
  34.                                        #2, #0, #38,      (* Alt-L *)
  35.                                        #2, #0, #18,      (* Alt-E *)
  36.                                        #2, #0, #16,      (* Alt-Q *)
  37.                                        #2, #0, #37,      (* Alt-K *)
  38.                                        #2, #0, #19,      (* Alt-R *)
  39.                                        #2, #0, #35,      (* Alt-H *)
  40.                                        #2, #0, #46,      (* Alt-C *)
  41.                                        #0);
  42.   makebackup = FALSE;
  43.  
  44. (*===========================================================================*)
  45. (* The main variables                                                        *)
  46. (*===========================================================================*)
  47.  
  48. VAR
  49.   eddata      : EDCB;          (* Editor control block                       *)
  50.   edit_size   : LONGINT;       (* Size of file                               *)
  51.   exitcode    : WORD;          (* Status code set by binary editor functions *)
  52.   exitcomcode : INTEGER;       (* Code for command used to leave editor      *)
  53.   fname       : STRING;        (* Input name of file being edited            *)
  54.  
  55.   windx       : WORD;          (* Places to save x and y                     *)
  56.   windy       : WORD;
  57.  
  58.   windx1      : BYTE;          (* Places to save x and y                     *)
  59.   windx2      : BYTE;
  60.   windy1      : BYTE;
  61.   windy2      : BYTE;
  62.  
  63. TYPE
  64.   borderelements = (topleft, topright, botleft, botright, horiz, vert);
  65.   borderchars = ARRAY[borderelements] OF CHAR;
  66.  
  67. CONST
  68.   border :   borderchars = '┌┐└┘─│';
  69.   noborder : borderchars = '      ';
  70.  
  71. (*===========================================================================*)
  72. (* Debugging control                                                         *)
  73. (*===========================================================================*)
  74.  
  75. IMPLEMENTATION
  76.  
  77.   USES
  78.     DOS,
  79.     CRT,
  80.     bbdummy,
  81.     bbdump,
  82.     bbover,
  83.     bbtask,
  84.     bbwin;
  85.  
  86. (*===========================================================================*)
  87. (* User-Event check.  Called by editor periodically to allow us to switch    *)
  88. (* Note the user event handler must have a FAR attribute                     *)
  89. (*===========================================================================*)
  90.  
  91. PROCEDURE usereventcheck(eventno, kbdflaginfo : WORD);
  92.  
  93.     VAR
  94.       save_x   : BYTE;
  95.       save_y   : BYTE;
  96.       wind_max : WORD;
  97.       wind_min : WORD;
  98.  
  99.     BEGIN;
  100.  
  101.       IF NOT active_tcb^.tcb_no_overlay THEN
  102.         BEGIN;
  103.           WRITELN('Event check with overlay enabled');
  104.           dump_string('Event check with overlay enabled');
  105.           dump_trace;
  106.           HALT;
  107.         END;
  108.  
  109.       (*---------------------------------------------------------------------*)
  110.       (* Save current cursor location and window                             *)
  111.       (*---------------------------------------------------------------------*)
  112.  
  113.       wind_min := WINDMIN;
  114.       wind_max := WINDMAX;
  115.       save_x   := WHEREX;
  116.       save_y   := WHEREY;
  117.  
  118.       (*---------------------------------------------------------------------*)
  119.       (* Switch tasks                                                        *)
  120.       (*---------------------------------------------------------------------*)
  121.  
  122.       task_switch;
  123.  
  124.       (*---------------------------------------------------------------------*)
  125.       (* Restore current cursor location                                     *)
  126.       (*---------------------------------------------------------------------*)
  127.  
  128.       WINDOW(LO(wind_min) + 1,
  129.              HI(wind_min) + 1,
  130.              LO(wind_max) + 1,
  131.              HI(wind_max) + 1);
  132.  
  133.       GOTOXY(save_x, save_y);
  134.  
  135.     END;
  136.  
  137. PROCEDURE executeeditor;
  138.  
  139.   BEGIN;
  140.  
  141.     overlay_save;
  142.     active_tcb^.tcb_no_overlay := TRUE;
  143.  
  144.     exitcomcode := usebinaryeditor(eddata, '');
  145.  
  146.     active_tcb^.tcb_no_overlay := FALSE;
  147.     overlay_restore;
  148.  
  149.   END;
  150.  
  151. END.
  152.